#include "Col.ph"
#ifdef __GNUG__
#pragma implementation
#endif

#include "ContainerTypes.h"

#include "Object.h"

//----- comparison functions (for the sake of the global name space)
//      Note that a function XXX does exactly the same as its counterpart pXXX.
//      There are two implementation to keep compilers happy.

int ContainerTypes::Compare(Object *op1, Object *op2)
{
	return op1->Compare(op2);
}

bool ContainerTypes::Equal(Object *op1, Object *op2)
{
	return op1->IsEqual(op2);
}

u_long ContainerTypes::Hash(Object *op)
{
	return op->Hash();
}

bool ContainerTypes::Identical(Object *op1, Object *op2)
{
	return (op1 == op2);
}

u_long ContainerTypes::HashPtr(Object *op)
{
	return u_long(op);
}

#define CastObjPtr(p) ((Object*)p)

int ContainerTypes::pCompare(void *p1, void *p2)
{
	return CastObjPtr(p1)->Compare(CastObjPtr(p2));
}

bool ContainerTypes::pEqual(void *p1, void *p2)
{
	return CastObjPtr(p1)->IsEqual(CastObjPtr(p2));
}

u_long ContainerTypes::pHash(void *p)
{
	return CastObjPtr(p)->Hash();
}

bool ContainerTypes::pIdentical(void *p1, void *p2)
{
	return p1 == p2;
}

u_long ContainerTypes::pHashPtr(void * p)
{
	return u_long(p);
}

#define CastObj(p) ((Object**)p)

int ppCompare(const void *a, const void *b)
{
	if (*CastObj(a) == 0 || *CastObj(b) == 0)
		return 0;
	return (*CastObj(a))->Compare(*CastObj(b));
}

